{include file="public/header"}

<body>
  <div class="layui-fluid">
    <div class="layui-row">
      <form action="" method="post" class="layui-form layui-form-pane">
        <div class="layui-card layui-form" lay-filter="component-form-element">
          <div class="layui-card-header">配置名</div>
          <div class="layui-card-body layui-row layui-col-space10">
            <div class="layui-col-md12">
              <input type="text" value="{$row.remark|default=''}" required="" lay-verify="required" autocomplete="off"
                class="layui-input" disabled />
            </div>
          </div>
        </div>
        {if !empty($row.name) && $row.name == 'intergal'}
        <div class="layui-card layui-form" lay-filter="component-form-element">
          <div class="layui-card-header">配置值</div>
          <div class="layui-card-body layui-row layui-col-space10">
            <div class="layui-col-md12">
              <input type="text" value="{$row.value|default=''}" required="" name="value" lay-verify="required"
                class="layui-input" />
            </div>
          </div>
        </div>
        {/if}
        {if !empty($row.name) && $row.name == 'signrange'}
        <div class="layui-card layui-form" lay-filter="component-form-element">
          <div class="layui-card-header">内勤打卡坐标范围(单位：千米)</div>
          <div class="layui-card-body layui-row layui-col-space10">
            <div class="layui-col-md12">
              <input type="number" value="{$row.value|default=''}" required="" name="value" lay-verify="required"
                class="layui-input" />
            </div>
          </div>
        </div>
        {/if}
        {if !empty($row.name) && $row.name == 'signaddress'}
        <div class="layui-card layui-form" lay-filter="component-form-element">
          <div class="layui-card-header">内勤打卡地址</div>
          <div class="layui-card-body layui-row layui-col-space10">
            <div class="layui-col-md12">
              <a target="_blank" href="https://developer.amap.com/tools/picker">坐标获取工具，请将坐标获取结果粘贴至内勤打卡坐标
                处 </a>
              <a class="layui-btn layui-btn-btn layui-btn-sm layui-btn-normal" onclick="addtable2()">添加内勤打卡地址</a>
              <table class="layui-table layui-form" style="border:1px solid #ccc;" id="table2" lay-filter="table2">
                <thead>
                  <tr>
                    <td>
                      <div class="layui-table-cell">序号</div>
                    </td>
                    <td>
                      <div class="layui-table-cell">内勤打卡地址</div>
                    </td>
                    <td>
                      <div class="layui-table-cell">内勤打卡坐标</div>
                    </td>
                    <td>
                      <div class="layui-table-cell">操作</div>
                    </td>
                  </tr>
                </thead>
                <tbody>
                  {foreach $row.value as $k => $data}
                  <tr>
                    <td>{$k+1}</td>
                    <td><input placeholder="例：长沙现代服务产业园" required="" lay-verify="required" type="text" class="layui-input" name="value[{$k}][address]" value="{$data.address|default='0'}"/></td>
                    <td><input placeholder="例：长沙现代服务产业园" required="" lay-verify="required" type="text" class="layui-input" name="value[{$k}][latlng]" value="{$data.latlng|default='0'}"/></td>
                    <td><a class="layui-btn layui-btn-danger layui-btn-xs del">删除</a></td>
                  </tr>
                  {/foreach}
                </tbody>
              </table>
            </div>
          </div>
        </div>
        {/if}
        {if !empty($row.name) && $row.name == 'signtime'}
        <div class="layui-card layui-form" lay-filter="component-form-element">
          <div class="layui-card-header">打卡时间</div>
          <div class="layui-card-body layui-row layui-col-space10">
            <div class="layui-col-md12">
              上班时间：<input type="text" id="test1" value="{$row.value.mon|default=''}" required="" name="value[mon]"
                lay-verify="required" class="layui-input" />
              下班时间:<input type="text" id="test2" value="{$row.value.aft|default=''}" required="" name="value[aft]"
                lay-verify="required" class="layui-input" />
            </div>
          </div>
        </div>
        {/if}
        {if !empty($row.name) && ($row.name == 'myus' || $row.name ==
        'irule')}
        <div class="layui-card layui-form" lay-filter="component-form-element">
          <div class="layui-card-body layui-row layui-col-space10">
            <div class="layui-col-md12">
              <textarea id="infos" name="value">
                      {if !empty($row.value)}{:htmlspecialchars_decode($row.value)}{/if}</textarea>
            </div>
          </div>
        </div>
        {/if}
        <div class="layui-form-item">
          <input type="hidden" value="{$row['name']|default=''}" name="name" />
          <button class="layui-btn" lay-submit="" lay-filter="add">提交</button>
        </div>
      </form>
    </div>
  </div>
  {include file="public/footer"}
  <script src="/static/leyedit/Layui-KnifeZ/layui.all.js"></script>
  <script src="/static/leyedit/ace/ace.js"></script>
  <script>
    function addtable2() {
      var i = $('#table2 tbody tr').length;
      //你要添加的html
      var html = '<tr>';
      html += '<td>' + (i + 1) + '</td>';
      html += '<td><input placeholder="例：长沙现代服务产业园" required="" lay-verify="required" type="text" class="layui-input" name="value[' + i + '][address]"' + ' /></td>';
      html += '<td><input placeholder="例：113.08,28.21" required="" lay-verify="required" type="text" class="layui-input" name="value[' + i + '][latlng]"' + ' /></td>';
      html += '<td><a class="layui-btn layui-btn-danger layui-btn-xs del">删除</a></td>';
      html += '</tr>';
      $(html).appendTo($('#table2 tbody:last'));
      layui.use(['form'], function () {
        $ = layui.jquery;
        var form = layui.form;
        form.render();
      });
    }
    function addtable3() {
      var i = $("#table3 tbody tr").length;
      //你要添加的html
      var html =
        "<tr>" +
        '<td><input required="" lay-verify="required" type="text" id="layui-input" class="layui-input" name="value[shop][' +
        i +
        '][key]" value=""></td>' +
        '<td><input required="" lay-verify="required" type="number" id="layui-input" class="layui-input" name="value[shop][' +
        i +
        '][value]" value=""></td>' +
        '<td><a class="layui-btn layui-btn-danger layui-btn-xs del" >删除</a></td></tr>';
      $(html).appendTo($("#table3 tbody:last"));
      layui.use(["form"], function () {
        $ = layui.jquery;
        var form = layui.form;
        form.render();
      });
    }
    function addtable4() {
      var i = $("#table4 tbody tr").length;
      //你要添加的html
      var html =
        "<tr>" +
        '<td><input required="" lay-verify="required" type="text" id="layui-input" class="layui-input" name="value[orderuser][' +
        i +
        '][key]" value=""></td>' +
        '<td><input required="" lay-verify="required" type="number" id="layui-input" class="layui-input" name="value[orderuser][' +
        i +
        '][value]" value=""></td>' +
        '<td><a class="layui-btn layui-btn-danger layui-btn-xs del" >删除</a></td></tr>';
      $(html).appendTo($("#table4 tbody:last"));
      layui.use(["form"], function () {
        $ = layui.jquery;
        var form = layui.form;
        form.render();
      });
    }
    function addtable5() {
      var i = $("#table5 tbody tr").length;
      //你要添加的html
      var html =
        "<tr>" +
        '<td><input required="" lay-verify="required" type="text" id="layui-input" class="layui-input" name="value[monethclass][' +
        i +
        '][key]" value=""></td>' +
        '<td><input required="" lay-verify="required" type="number" id="layui-input" class="layui-input" name="value[monethclass][' +
        i +
        '][value]" value=""></td>' +
        '<td><input required="" lay-verify="required" type="number" id="layui-input" class="layui-input" name="value[monethclass][' +
        i +
        '][times]" value=""></td>' +
        '<td><input required="" lay-verify="required" type="number" id="layui-input" class="layui-input" name="value[monethclass][' +
        i +
        '][min]" value=""></td>' +
        '<td><input required="" lay-verify="required" type="number" id="layui-input" class="layui-input" name="value[monethclass][' +
        i +
        '][max]" value=""></td>' +
        '<td><a class="layui-btn layui-btn-danger layui-btn-xs del" >删除</a></td></tr>';
      $(html).appendTo($("#table5 tbody:last"));
      layui.use(["form"], function () {
        $ = layui.jquery;
        var form = layui.form;
        form.render();
      });
    }
    $("body").on("click", ".del", function () {
      $(this).closest("tr").remove();
    });
    layui.use(["form", "layer", "upload", "upload", "layedit", 'laydate'], function () {
      $ = layui.jquery;
      var form = layui.form,
        upload = layui.upload,
        element = layui.element,
        laydate = layui.laydate,
        layer = layui.layer,
        layedit = layui.layedit;
      laydate.render({
        elem: '#test1'
        , type: 'time'
        , format: 'HH:mm'
      });
      laydate.render({
        elem: '#test2'
        , type: 'time'
        , format: 'HH:mm'
      });
      layedit.set({
        //暴露layupload参数设置接口 --详细查看layupload参数说明
        uploadImage: {
          url: "/Base/upload_img",
          accept: "image",
          acceptMime: "image/*",
          exts: "jpg|png|gif|bmp|jpeg",
          size: "100240",
        },
        //右键删除图片/视频时的回调参数，post到后台删除服务器文件等操作，
        //传递参数：
        //图片： imgpath --图片路径
        //视频： filepath --视频路径 imgpath --封面路径
        calldel: {
          url: "/Base/upload_img",
        },
        //开发者模式 --默认为false
        devmode: false,
        //插入代码设置
        codeConfig: {
          hide: true, //是否显示编码语言选择框
          default: "javascript", //hide为true时的默认语言格式
        },

        tool: [
          "strong",
          "italic",
          "underline",
          "del",
          "|",
          "left",
          "center",
          "right",
        ],
        height: "300px",
      });
      var infos = layedit.build("infos");
      //监听提交
      form.on("submit(add)", function (data) {
        //发异步，把数据提交给php
        if (data.field.name == "myus" || data.field.name == "irule") {
          data.field.value = layedit.getContent(infos);
        }
        $.ajax({
          type: "post",
          data: data.field,
          success: function (res) {
            if (res.status == 0) {
              layer.msg(res.msg, { icon: 6, time: 1000 }, function () {
                // 获得frame索引
                var index = parent.layer.getFrameIndex(window.name);
                parent.location.reload();
                parent.layer.close(index);
              });
            } else {
              layer.msg(res.msg, { icon: 2, time: 1000 });
            }
          },
        });
        return false;
      });
    });
  </script>
</body>